/**
 * Created by ptt on 2016/5/27/0027.
 */
define(["../maintools/Controller.js", "./tpl.js"], function (Controller, tpl) {
    //initial
    tpl = tpl.popup;
    Controller = Controller.Controller;
    $("#popup").html(tpl.render());
    var Trigger = Controller.create({
        show: function () {
            var popup = this.el;
            popup.removeClass("hidden");
            popup.css("opacity", "0");
            popup.animate({
                opacity: "1"
            })
        },
        hide: function () {
            var popup = this.el;
            popup.animate({
                opacity: "0"
            }, 300, function () {
                popup.addClass("hidden");
            });
        },
        toggle: function () {
            var popup = this.el;
            popup.hasClass("hidden") ? this.show() : this.hide();
        }
    });
    var popup = new Trigger("#popup");
    popup.show();
    return {
        popupController: popup
    };
    //handle.initial();
    //var mainPopup = $("#popup").find("div.css-popup");
    ////listener
    //mainPopup.on("click", "dd", function (e) {
    //    var elem = $(this);
    //    handle.toggleLayer(elem.attr("data-url"), elem.attr("data-title"), elem.attr("data-content"));
    //});
    //mainPopup.on("mousedown", "dd", function (e) {
    //    $(this).addClass("click");
    //});
    //mainPopup.on("mouseup", "dd", function (e) {
    //    $(this).removeClass("click");
    //});
    //
    //mainPopup.on("click", "button.js-next", function (e) {
    //    console.log(1);
    //    handle.getNext();
    //});
    //mainPopup.on("click", "button.js-pre", function (e) {
    //    console.log(1);
    //    handle.getPre();
    //});
});